package com.af.example.plugins;

import com.af.example.plugins.spi.AfMessagePlugin;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @author : zhenyun.su
 * @since : 2024/6/18
 */

public class AfFactoryPlugin {
    public static void main(String[] args) {
        ServiceLoader<AfMessagePlugin> plugins = ServiceLoader.load(AfMessagePlugin.class);
        Iterator<AfMessagePlugin> iterator = plugins.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next().send("hello"));
        }
        // plugins.forEach(plugin -> {
        //     System.out.println(plugin.send("hello"));
        // });
    }
}
